package xx.iverson.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * xx.iverson.result.ReturnResult
 * 统一返回结果类
 * on 2025/6/18-下午2:44
 *
 * @author weijx
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReturnResult<T> {
    private int code;
    private String message;
    private T data;

    public static <T> ReturnResult<T> success(String message,T data) {
        ReturnResult<T> result = new ReturnResult<>();
        result.setCode(200);
        result.setMessage(message);
        result.setData(data);
        return result;
    }


    public static <T> ReturnResult<T> error(int code, String message,T data) {
        ReturnResult<T> result = new ReturnResult<>();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }


}